// 简单封装 alert toast  方法
function alert (content, title = '提示', isCancel = false) {
    return new Promise((resolve, reject)=>{
      uni.showModal({
        title: title,
        content: content,
        confirmColor: '#63a55a',
				showCancel: isCancel,
        success(res) {
					if (res.confirm) {
						resolve(); 
					}
        },
        fail() {
          reject();
        }
      });
    })
  };
  
  function toast (msg, icon = '', timer = 1000) {
    var image = '';
    if (!icon) {
      icon = 'none';
    }
    switch (icon) {
      case 'success':
        icon = 'success';
        break;
      case 'loading':
        icon = 'loading';
        break;
      case 'error':
        image = '/picture/msg-error.png';
        break;
      case 'none':
        image = '';
        break;
      default:
        image = icon;
    }
    return new Promise((resolve, reject)=>{
      uni.showToast({
        icon: icon,
        image: image,
        title: msg,
        duration: timer,
        mask: true,
        success() {
           resolve();
        },
        fail(err) {
          // reject(err);
        }
      });
    });
  }
  
module.exports = {
	alert,
	toast
}